package com.zzw.hj20;

import java.util.Scanner;

/**
 * @Project: hw_java
 * @Description: 密码验证合格程序
 * @Author: zzw
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String password = scanner.nextLine();
            isValid(password);
        }
    }

    private static void isValid(String password) {

        if (password.length() < 8) {
            System.out.print("NG");
            return;
        }

        char[] letter = password.toCharArray();
        int upperCaseLetter = 0;
        int lowercaseLetter = 0;
        int number = 0;
        int other = 0;
        for (char c : letter) {
            if (c >= 'a' && c <= 'z') {
                lowercaseLetter = 1;
            } else if (c >= 'A' && c <= 'Z') {
                upperCaseLetter = 1;
            } else if (c >= '0' && c <= '9') {
                number = 1;
            } else {
                other = 1;
            }
        }
        if (upperCaseLetter + lowercaseLetter + number + other < 3) {
            System.out.println("NG");
        } else {
            boolean isValid = true;
            for (int i = 0; i < letter.length - 3; i++) {
                for (int j = i + 1; j <= letter.length - 3; j++) {
                    if (letter[i] == letter[j] && letter[i + 1] == letter[j + 1] &&
                            letter[i + 2] == letter[j + 2]) {
                        isValid = false;
                        break;
                    }
                }
            }
            if (isValid) {
                System.out.println("OK");
            } else {
                System.out.println("NG");
            }

        }

    }
}
